﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;


namespace MVCCentral.Framework
{
    public class MD5Hasher
    {
        public static string GetEmailHash(string email)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();

            UTF8Encoding encoder = new UTF8Encoding();
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();

            byte[] hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(email));

            StringBuilder sb = new StringBuilder(hashedBytes.Length * 2);
            for (int i = 0; i < hashedBytes.Length; i++)
            {
                sb.Append(hashedBytes[i].ToString("X2"));
            }
            return sb.ToString().ToLower().Trim();
        }
    }
}
